/*
 *本地缓存、会话缓存
 * @Author: 舒克
 * @Official Accounts: 氧化1028
 * @email: 143587623@qq.com
 * @github: https://gitee.com/KingSio
 * @Date: 2021-01-06 11:29:03
 * @LastEditTime: 2021-03-18 09:34:39
 * @FilePath: \个人项目\vue\1.vue全站管理系统\vue_shop\src\utils\Storage.js
 */

 //使用class创建对象
 class Storage{
    localStorageSetItem(key,value){
        window.localStorage.setItem(key,JSON.stringify(value))

    }
    //取
    localStorageGetItem(key){
        return JSON.parse(window.localStorage.getItem(key))

    }
    //移除
    localStorageRemove(key){
		window.localStorage.remove(key);
    }
    
    //会话缓存
    sessionSetItem(key,value){
        window.sessionStorage.setItem(key,JSON.stringify(value))

    }
    //取
    sessionGetItem(key){
        return JSON.parse(window.sessionStorage.getItem(key))

    }
    //移除
    sessionStorageRemove(key){
        window.sessionStorage.removeItem(key);
    }
 }
 //class语法糖，必须new
 const storage=new Storage()
/* let storage={
    //本地缓存
    //存
    localStorageSetItem(key,value){
        window.localStorage.setItem(key,JSON.stringify(value))

    },
    //取
    localStorageGetItem(key){
        return JSON.parse(window.localStorage.getItem(key))

    },
    //移除
    localStorageRemove(key){
		window.localStorage.remove(key);
    },
    
    //会话缓存
    sessionSetItem(key,value){
        window.sessionStorage.setItem(key,JSON.stringify(value))

    },
    //取
    sessionGetItem(key){
        return JSON.parse(window.sessionStorage.getItem(key))

    },
    //移除
    sessionStorageRemove(key){
        window.sessionStorage.removeItem(key);
    }

} */

export default storage
